package com.yanqu.road.server.cmd.activity.treasure;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.pb.treasureactivity.TreasureActivityProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.treasure.TreasureActivityModule;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_ACTIVITY_TREASURE_NOTIFY_CONSUME_GOODS, desc = "灵狐寻宝通知消耗道具")
public class TreasureNotifyConsumeGoodsCmd extends AbstractCommand {

    int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        TreasureActivityProto.TreasureNotifyConsumeGoodsReqMsg reqMsg = TreasureActivityProto.TreasureNotifyConsumeGoodsReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ActivityInfo activityInfo = NormalActivityMgr.getActivityInfo(activityId);
        if (null != activityInfo && activityInfo.getType() == eActivityType.TreasureActivity.getValue()) {
            player.getModule(TreasureActivityModule.class).autoUseActivityGoods(activityInfo);
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
